<?php
	include_once("include/public.php");
	$content = POSTS("content");
	$username = POSTS("username");
	$contact = POSTS("contact");
	$time = date("Y-m-d H:i:s");
	$sql = "insert into guestbook(content,name,contact,active) values('{$content}','{$username}','{$contact}','{$time}')";
	$result = $db->query($sql);
	if($result === false)
	{
		msg(0,'发表留言失败');
	}
	else
	{
		msg(1,'发表留言成功');
	}

	function msg($no,$msg,$autoid = 0){
		$json = new Services_JSON();
		$msg = array("no"=>$no,"msg"=>$msg,"autoid"=>$autoid);
		echo $json->encode($msg);
		die();
	}
?>